home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Scene Storm
/
Scene Storm - Volume 1.iso
/
coding
/
c
/
dependantscan
/
source
/
requestererror.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-11-14
|
8KB
|
144 lines
#define DEF_REQUESTERERROR_C
#include <exec/types.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <stdio.h>
#include <stdarg.h>
#include "RequesterError.h"
static struct Window *ErrorRequesterWindow = NULL; /* default screen for error requesters to show up on */
static char *ErrorRequesterTitle = NULL; /* how we will title error requesters */
static char *(*ErrorLocaleFunction)(int message_index) = NULL; /* function to call to get an error message for this applicaiton */
static char *ErrorGadgetText = NULL; /* description of the gadget(s) on the error requesters */
/*
void requester_error_set_defaults(
struct Window *window, the screen to display error requesters on
char *title, the title of error requesters
char *(*locale_function)(int message_index), a function to call to be get error messages
char *gadget_text) the text to be used for the gadget(s) on the requesters
* Description
This function optionally sets up the title of error requesters and/or the array of strings to be used for error messages. If any
argument is NULL, that item will not be changed.
*/
void requester_error_set_defaults(
struct Window *window, /* the screen to display error requesters on */
char *title, /* the title of error requesters */
char *(*locale_function)(int message_index), /* a function to call to be get error messages */
char *gadget_text) /* the text to be used for the gadget(s) on the requesters */
{
if (window) /* if we should set a default screen for our error requesters */
ErrorRequesterWindow = window; /* put error requests on the same screen as this window */
if (title) /* if we should change the name for the error requesters */
ErrorRequesterTitle = title; /* use this for the name of the error requesters */
if (locale_function) /* if a function to get error messages was supplied */
ErrorLocaleFunction = locale_function; /* use this function to get messages */
if (gadget_text) /* if we should change the default gadget text */
ErrorGadgetText = gadget_text; /* use this for the default gadget text */
}
/*
int vrequester_error(
struct Window *window, if non-NULL, show the requester window on the same screen as this window
char *title, if non-NULL, use this for the title
char *error_text, if non-NULL, use this for the error text
char *gadget_text, if non-NULL, use this for to define the available gadget(s)
int error_number, if 'error_text' is NULL, use ErrorLocaleFunction(error_number)
va_arg arg_ptr) printf() style arguments for the error text and gadget text
* Description
This function will display the specified error in a requester optionally entitled 'title' and wait for the user to choose something.
NOTE: Turn off all "Verify Messages" before using this routine. Use ModifyIDCMP() to turn off all messages such as MENUVERIFY before
calling this function. Neglecting to do so can cause situations where Intuition is waiting for the return of a message that the
application cannot receive because it's input is shut off while the requester created by this function is up.
This function requires that the intuition.library be open.
* Return Value
0 = the rightmost gadget was selected
> 1 = a leftmost gadget was selected (the number of the gadget is returned)
*/
int vrequester_error(
struct Window *window, /* if non-NULL, show the requester window on the same screen as this window */
char *title, /* if non-NULL, use this for the title */
char *error_text, /* if non-NULL, use this for the error text */
char *gadget_text, /* if non-NULL, use this for to define the available gadget(s) */
int error_number, /* if 'error_text' is NULL, use ErrorLocaleFunction(error_number) */
va_list arg_ptr) /* printf() style arguments for the error text and gadget text */
{
struct EasyStruct *easy_struct = AllocVec(sizeof(*easy_struct),0); /* the structure used to handle the requester */
int retval = 0; /* default to the cancel gadget */
if (easy_struct) /* if we could get enough memory */
{
easy_struct->es_StructSize = sizeof(*easy_struct); /* let intuition know which structure we are using */
easy_struct->es_Flags = 0; /* not yet used */
easy_struct->es_Title = title ? title : ErrorRequesterTitle; /* use appropriate title */
easy_struct->es_TextFormat = error_text ? error_text : ErrorLocaleFunction(error_number); /* fetch specified error text */
easy_struct->es_GadgetFormat = gadget_text ? gadget_text : ErrorGadgetText; /* use the appropriate gadget text */
retval = EasyRequestArgs(window ? window : ErrorRequesterWindow, easy_struct, NULL, arg_ptr);
FreeVec(easy_struct); /* don't need this memory anymore */
}
return (retval); /* 0 = righmost (cancel), other = gadget number */
}
/*
int requester_error(
struct Window *window, if non-NULL, show the requester on the same screen as this window
char *title, if non-NULL, use this for the title
char *error_text, if non-NULL, use this for the error text
char *gadget_text, if non-NULL, use this for to define the available gadget(s)
int error_number, if 'error_text' is NULL, access ErrorLocaleFunction(error_number)
...) printf() style arguments for the error text and gadget text
* Description
This funciton acts exactly like vrequester_error() except that it takes it's arguments individually.
* Return Value
see vrequester_error()
*/
int requester_error(
struct Window *window, /* if non-NULL, show the requester on the same screen as this window */
char *title, /* if non-NULL, use this for the title */
char *error_text, /* if non-NULL, use this for the error text */
char *gadget_text, /* if non-NULL, use this for to define the available gadget(s) */
int error_number, /* if 'error_text' is NULL, access ErrorLocaleFunction(error_number) */
...) /* printf() style arguments for the error text and gadget text */
{
va_list arg_ptr; /* for dealing with variable arguments */
va_start(arg_ptr,error_number); /* setup the variable argument stuff */
return (vrequester_error(window,title,error_text,gadget_text,error_number,arg_ptr)); /* call the va_arg version of this function */
}
/*
int quick_requester_error(
int error_number, index into the errory text array
...) printf() style arguments for the error text and gadget text
* Description
This function works exactly like requester_error() except that the values previously setup by a call to requester_error_set_defaults()
will be used instead of having to pass them on the stack.
*/
int quick_requester_error(
int error_number, /* index into the errory text array */
...) /* printf() style arguments for the error text and gadget text */
{
va_list arg_ptr; /* for dealing with variable arguments */
va_start(arg_ptr,error_number); /* setup the variable argument stuff */
return (vrequester_error(NULL,NULL,NULL,NULL,error_number,arg_ptr)); /* call the va_arg version of this function */
}